﻿using AppService.IService.System_operation;
using AppService.IService.System_order;
using Domain.Entity.System_dictionary;
using Domain.Entity.System_operation;
using Domain.Entity.System_Ordermanagement;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.System_operation
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Wb_meterController : ControllerBase
    {
        private readonly IWb_meterService Iwb_meterService;

        public Wb_meterController(IWb_meterService iwb_meterService)
        {
            Iwb_meterService = iwb_meterService;
        }

        /// <summary>
        /// 查询运单表的数据总数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int Count(string? Origin_place, string? Det_place, string? tran_manager, string? Wb_number)
        {
            return Iwb_meterService.Count(Origin_place, Det_place, tran_manager, Wb_number);
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [HttpGet("{currentPage},{PageSize}")]
        public List<Wb_meter> GetWb_meter(int currentPage, int PageSize)
        {
            return Iwb_meterService.GetWb_meter(currentPage, PageSize);
        }

        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="Origin_place"></param>
        /// <param name="Det_place"></param>
        /// <param name="Wb_number"></param>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Wb_meter> GetWb_Meters(string? Origin_place, string? Det_place, string? tran_manager, string? Wb_number, int currentPage, int PageSize)
        {
            return Iwb_meterService.GetWb_Meters(Origin_place, Det_place, tran_manager, Wb_number, currentPage, PageSize);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Wb_id"></param>
        /// <returns></returns>
        [HttpDelete("{Wb_id}")]
        public bool Delete(int Wb_id)
        {
            return Iwb_meterService.Delete(Wb_id);
        }

        /// <summary>
        /// 根据id查询数据
        /// </summary>
        /// <param name="Wb_id"></param>
        /// <returns></returns>
        [HttpGet("{Wb_id}")]
        public List<Wb_meter> GetWb_Meters_Wb_id(int Wb_id)
        {
            return Iwb_meterService.GetWb_Meters_wb_id(Wb_id);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="wb_Meter"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Update(Wb_meter? wb_Meter)
        {
            return Iwb_meterService.Update(wb_Meter);
        }

        /// <summary>
        /// 根据名称查询数据字典
        /// </summary>
        /// <param name="Dict_label"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Sys_dict_data> Get_Dict_Datas(string Dict_label)
        {
            return Iwb_meterService.Get_Dict_Datas(Dict_label);
        }

        /// <summary>
        /// 根据运单状态查询数量
        /// </summary>
        /// <param name="Wb_status"></param>
        /// <returns></returns>
        [HttpGet("{Wb_status}")]
        public int Count_status(string Wb_status)
        {
            return Iwb_meterService.Count_status(Wb_status);
        }

        /// <summary>
        /// 根据运单状态查询
        /// </summary>
        /// <param name="wb_status"></param>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [HttpGet("{wb_status},{currentPage},{PageSize}")]
        public List<Wb_meter> GetWb_Meters_status(string? wb_status, int currentPage, int PageSize)
        {
            return Iwb_meterService.GetWb_Meters_status(wb_status, currentPage, PageSize);
        }

        /// <summary>
        /// 添加提货单
        /// </summary>
        /// <param name="bill_Ol"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Add_Bill_ol(Bill_ol bill_Ol)
        {
            return Iwb_meterService.Add_Bill_ol(bill_Ol);
        }

        /// <summary>
        /// 根据订单id订单
        /// </summary>
        /// <param name="Ord_id"></param>
        /// <returns></returns>
        [HttpGet("{Ord_id}")]
        public List<Orders> GetOrders(int Ord_id)
        {
            return Iwb_meterService.GetOrders(Ord_id);
        }

        [HttpPut("{Wb_id}")]
        public bool Update_status(int Wb_id)
        {
            return Iwb_meterService.Update_status(Wb_id);
        }
    }
}
